<?php

define('WEBKEY', 'wertyuio');
define('PICTURE_ROOT_PATH', ROOT_PATH . 'public' . DS . 'uploads' . DS . 'picture' . DS);
define('FONT_PATH', ROOT_PATH . 'public' . DS . 'fonts' . DS);

function showPage($page,$totalPage,$where=null,$sep="&nbsp;",$flag="index.php/"){
	$p        = '';
	$where    = ($where==null) ? null : "&".$where;
	$url      = $_SERVER ['PHP_SELF'];
	$url      = str_replace($flag, "", $url);
	$index    = ($page == 1) ? "首页" : "<a href='{$url}?page=1{$where}'>首页</a>";
	$last     = ($page == $totalPage) ? "尾页" : "<a href='{$url}?page={$totalPage}{$where}'>尾页</a>";
	$prevPage = ($page>=1)?$page-1:1;
	$nextPage = ($page>=$totalPage)?$totalPage:$page+1;
	$prev     = ($page == 1) ? "上一页" : "<a href='{$url}?page={$prevPage}{$where}'>上一页</a>";
	$next     = ($page == $totalPage) ? "下一页" : "<a href='{$url}?page={$nextPage}{$where}'>下一页</a>";
	$str      = "总共{$totalPage}页/当前是第{$page}页";

	for($i = 1; $i <= $totalPage; $i ++) {
		//当前页无连接
		if ($page == $i) {
			$p .= "[{$i}]";
		} else {
			$p .= "<a href='{$url}?page={$i}{$where}'>[{$i}]</a>";
		}
	}

 	$pageStr=$str. $sep .$index. $sep. $prev. $sep .$p. $sep .$next. $sep .$last;
 	return $pageStr;
}


function autoLoginFlagEncode($array){
	$string = implode(':',$array);
	$cookieValue = base64_encode($string);
	return $cookieValue;
}

function autoLoginFlagDecode($str){
	$string = base64_decode($str);
	$cookieValue = explode(':', $string);
	return $cookieValue;
}